<?php
/*
 * Created on 06.01.2006
 *
 * Tags support class
 *
 */
 
class dbaCMSObjectTags
{
    
    var $dba;

    function dbaCMSObjectTags (&$dba)
    {    
        $this->dba = &$dba;
    }
    
    function getCategoriesAsAttributes ($id, $type)
    {
        $pub = '';
        if (isset($GLOBALS['is_live']) && $GLOBALS['is_live'])
            $pub = 'Pub';
        $sth = $this->dba->query("select O.*, PA.name as parent from ".$this->dba->tableforwarder.
            "_cms${pub}Type_$type P, ".$this->dba->tableforwarder."_cmsObjCat O, ".
            $this->dba->tableforwarder."_cmsElementObjCat E, ".$this->dba->tableforwarder."_cmsObjCat PA where " .
            "P.element_id = E.element_id and O.id = E.cat_id and PA.id = O.parent_id " .
            "and P.element_id=$id");
        if (is_object($sth))
        {
            $attrs = array();
            $rows = $sth->fetch_rows_array();
            for ($i = 0; $i < count($rows); $i++)
            {
                $attrs[$rows[$i]['parent']] = $rows[$i]['name'];
            }
            return $attrs;
        }
    }

}

?>
